import Koa from 'koa'
import Router from 'koa-router'
import { createMogodb } from '../db'

export async function createView(config: any) {
    const router = new Router()
    const { lengthPage, size, col = 'proxyLists' } = config

    // const proxyControllerService = new ProxyControllerImpl(client, size, lengthPage)

    // router.get('/', async (ctx: Koa.ParameterizedContext<Koa.DefaultState, Koa.DefaultContext, any>, next) => {
    //     const res = await proxyControllerService.findAll(1)
    //     await ctx.render('index', { res: res })
    // })

    // router.get('/:page', async (ctx: Koa.ParameterizedContext<Koa.DefaultState, Koa.DefaultContext, any>, next) => {
    //     const nowPage = ctx.params.page
    //     const res = await proxyControllerService.findAll(nowPage)
    //     await ctx.render('index', { res: res })
    // })

    // router.get('/proxy/params', async (ctx: Koa.ParameterizedContext<Koa.DefaultState, Koa.DefaultContext, any>, next) => {
    //     const condition = ctx.query
    //     const res = await proxyControllerService.findByParams(condition, 1)
    //     await ctx.render('index', { res: res })
    // })


    // router.get('/proxy/params/:page', async (ctx: Koa.ParameterizedContext<Koa.DefaultState, Koa.DefaultContext, any>, next) => {
    //     const condition = ctx.query
    //     const nowPage = ctx.params.page
    //     const res = await proxyControllerService.findByParams(condition, nowPage)
    //     await ctx.render('index', { res: res })
    // })



    const ret = router.routes()
    return ret
}